# Maintainer: Guy Godfroy <guy.godfroy@gugod.fr>
pkgname=prometheus-opnsense-exporter
_pkgname=opnsense-exporter
pkgver=0.0.5
pkgrel=0
pkgdesc="Prometheus exporter for OPNSense"
url="https://github.com/AthennaMind/opnsense-exporter"
license="Apache-2.0"
arch="all"
makedepends="go"
install="$pkgname.pre-install $pkgname.pre-upgrade"
subpackages="$pkgname-openrc"
source="$_pkgname-$pkgver.tar.gz::https://github.com/AthennaMind/opnsense-exporter/archive/v$pkgver.tar.gz
	opnsense-exporter.initd
	opnsense-exporter.confd
	"
builddir="$srcdir/$_pkgname-$pkgver"
options="!check net" # no test suite available

build() {
	go build \
		-ldflags "-X github.com/prometheus/common/version.Version=$pkgver" \
		-v -o opnsense-exporter
}

check() {
	go test ./...
}

package() {
	install -Dm755 opnsense-exporter "$pkgdir"/usr/bin/opnsense-exporter

	install -Dm755 "$srcdir"/opnsense-exporter.initd "$pkgdir"/etc/init.d/opnsense-exporter
	install -Dm644 "$srcdir"/opnsense-exporter.confd "$pkgdir"/etc/conf.d/opnsense-exporter
}

sha512sums="
7f28b9f27b71f3d6a780aad5c27d26730ef24dfef801709bb793881bf7fedd197bc4dededaaf68123cc8ee97d0ab32826f4ae708a9cafdb8a802262556a0adb7  opnsense-exporter-0.0.5.tar.gz
6ea912d9ded233ac09802f2f08aaf3e4a6d830fe5164435ba8d8bfdd74874c1855649f0c9127d18b0047c7fe7991631d8c7602c9faa41a79da98d0bd8ded58c0  opnsense-exporter.initd
77b35cef4066b2d8a119467a02f2d7946d9d8a38622e0fd1a90c36f7a43a247ef580b613ca361a01bd3df4b03b236f71b9e118e3172c729c9e7c594875f43cf6  opnsense-exporter.confd
"
